import org.omg.CORBA.PUBLIC_MEMBER;
class OuterClass {//外部类
    public int data1 = 1;
    public static int data2 = 2;
    private int data3 = 3;

    //实例内部类
    class InnerClass {//内部类
        public int data1 = 111;
        public int data4 = 4;
        public static final int data5 = 5;//编译的时候就确定
        private int data6 = 6;

        public void test() {
            System.out.println("InnerClass::test()");
            System.out.println(this.data1);//对于实例内部类，包含2个this
            System.out.println(OuterClass.this.data1);
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }
    }
    public void test() {
        InnerClass innerClass = new InnerClass();
        System.out.println("OuterClass::test()");
    }
}
class Out{
    public int data1 = 1;
    public static int data2 = 2;
    private int data3 = 3;

    //静态内部类
    static class InnerClass {
        public int data4 = 4;
        public static int data5 = 5;
        private int data6 = 6;

        public void test() {
            Out out = new Out();
            System.out.println(out.data1);
            System.out.println(data2);
            System.out.println(out.data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
            System.out.println("InnerClass：：test()");
        }
    }

    public void test() {
        System.out.println("Out：：test()");
    }
}
//匿名内部类
interface IA {
    void test();
}
public class Test2 {
    public static void main(String[] args) {
        //new IA()    ;
//匿名内部类对象
        IA a = new IA() {
            @Override
            public void test() {
                System.out.println("这是重写了接口的方法！");
            }
        };

        a.test();

        new IA() {
            @Override
            public void test() {
                System.out.println("这是重写了接口的方法！");
            }
        }.test();

    }
    //局部内部类
    public void func() {
        class AA {
            public int a;
        }

        AA aa = new AA();
        System.out.println(aa.a);
    }

    public static void main2(String[] args) {
        Out.InnerClass innerClass = new Out.InnerClass();
        innerClass.test();
    }
    public static void main1(String[] args) {
        OuterClass outerClass = new OuterClass();

        //OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        OuterClass.InnerClass innerClass = new OuterClass().new InnerClass();
        innerClass.test();

    }
}